package earogya.ehr.patient_details.ws;
import java.io.IOException;

import ca.uhn.hl7v2.HL7Exception;

/**
 * 
 * Service interface provided to access the patient details service
 * 
 * @author Ureka
 *
 */
public class EHRPatientDetailsServiceInterface {
	
	/**
	 * 
	 * Get the HL7 message and modify it and sends it to the message handler
	 * 
	 * @param msg
	 * @return
	 * @throws HL7Exception
	 * @throws IOException
	 */
	public String handlePatientDetailsMessage(String msg)throws HL7Exception, IOException{
		HL7MessageHandler h=new HL7MessageHandler();
		String ack=h.parser(this.modifyMessage(msg));
		return ack;
	}
	
	/**
	 * 
	 * Modify the HL7 message by removing some characters so that it can be parsed
	 * 
	 * @param message
	 * @return
	 */
	private String modifyMessage(String message){
		String newMessage=null;
		newMessage=message.replaceAll("\n", "\r");
		return newMessage;
	}	
}
